package com.longfei.admin.imageloder_text;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;

/**
 * 1、 Universal-ImageLoader的配置
 *
 * 2、用Universal-ImageLoader加载网络图片和本地图片
 *
 * @author Administrator
 */


public class MainActivity extends Activity {
    private ImageLoader loader;
    private ImageView iv_img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        loader=ImageLoader.getInstance();//实例化ImageLoder
        iv_img=(ImageView)findViewById(R.id.iv_img);

        String url="file:///"+"加载本地图片";

        //加载网络图片，第一个参数为路径
//        loader.displayImage("http://static.oschina.net/uploads/user/494/988131_100.jpg?t=1419303093000",iv_img);

        loader.displayImage("http://static.oschina.net/uploads/user/494/988131_100.jpg?t=1419303093000", iv_img, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String s, View view) {
                Log.i("info","加载开始");

            }

            @Override
            public void onLoadingFailed(String s, View view, FailReason failReason) {
                Log.i("info","加载失败");

            }

            @Override
            public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                Log.i("info","加载完毕");

            }

            @Override
            public void onLoadingCancelled(String s, View view) {
                Log.i("info","加载取消");

            }
        });
    }
}
